<?php 
define('DB_TABLE_PRE','cj_');//表前缀
define('IMG_SAVE_PATH','/var/www/website/cms.wondershare.com/httpdocs/image2/cj_img/');
define('IMG_UPLOAD_PATH',IMG_SAVE_PATH.'upload/');
define('IMG_BG_PATH',IMG_SAVE_PATH.'bg/');
 
require_once '../../conf/conf.php';
require_once '../ws_qrj/lib/Mysql.class.php';


$db = new Mysql();

if( isset($_GET['m']) && $_GET['m'] == 'change'){
	$db->update('photo',array('visit'=>$_GET['visit']), 'cid='.$_GET['cid']);
	exit;
}

if( $_GET['cid'] ){	
	$cid = $_GET['cid'];
	$d = $db->getOne('photo','cid='.$cid);
	
	if( !empty( $d )){
		$db->delete('photo','cid='.$cid);
		@unlink( IMG_UPLOAD_PATH.$d['photo'] );
		echo 'Success!';
	}else{
		echo 'Faile! No this photo!';
	}	
}

$data = $db->getAll('photo',1,'*','visit Desc');



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Like</title>
</head>

<body>
<table width="100%" border="1" cellspacing="1" cellpadding="1">
  <tr>
    <td>ID</td>
    <td>NAME</td>
    <td>EMAIL</td>
    <td>FROM</td>
    <td>TO</td>
    <td>WAY</td>
    <td>TIME</td>
    <td>VISIT</td>
    <td>IS_TOP20</td>
    <td>LIKE</td>
    <td>操作</td>
  </tr>
<?php foreach( $data as $v ){?>
  <tr>
    <td><?php echo $v['cid'];?></td>
    <td><?php echo $v['name'];?></td>
    <td><?php echo $v['email'];?></td>
    <td><?php echo $v['from'];?></td>
    <td><?php echo $v['to'];?></td>
    <td><?php echo $v['way'];?></td>
    <td><?php echo $v['time'];?></td>
    <td><input type="text" value="<?php echo $v['visit'];?>" size="6" onblur="C(<?php echo $v['cid'];?>,this)"/></td>
    <td><?php echo $v['is_top20'];?></td>
    <td><div class="addthis_toolbox addthis_default_style share" addthis:url="http://www.wondershare.com/topic/springbreak/finish.php?c=<?php echo $v['cid'];?>">
	<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a></div></td>
    <td><a href="see.php?cid=<?php echo $v['cid'];?>">删除</a></td>
  </tr>
  <?php }?>
</table>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e72b35b049dba8d"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
function C( cid, obj ){
	$.get('see.php?m=change',{cid:cid,visit:parseInt($(obj).val())})
}
</script>
</body>
</html>
